package com.example.config;

import com.example.interceptor.ManagerLoginInterceptor;
import com.example.interceptor.UserLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author DPH
 * @date 2022/12/12
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(new UserLoginInterceptor());
        InterceptorRegistration registration1 = registry.addInterceptor(new ManagerLoginInterceptor());
        registration.addPathPatterns("/client/**");
        registration.excludePathPatterns(
                "/client/login",
                "/client/register",
                "/client/*.html",
                "/client/*.css",
                "/client/*.js",
                "/"
        );
        registration1.addPathPatterns("/manager/**");
        registration1.excludePathPatterns(
                "/manager/login",
                "/manager/*.html",
                "/manager/*.css",
                "/manager/*.js",
                "/"
        );
    }
}
